<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link href="<%=request.getContextPath()%>/css/global.css" type="text/css" rel="stylesheet" />
<link href="<%=request.getContextPath()%>/js/easyui/themes/metro/easyui.css" type="text/css" rel="stylesheet" />
<link href="<%=request.getContextPath()%>/js/date/skin/WdatePicker.css" type="text/css" rel="stylesheet" />
<link href="<%=request.getContextPath()%>/js/autocomplate/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/easyui/easyui.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/date/WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/autocomplate/jquery.autocomplete.js"></script>
<script type="text/javascript">
	$(function() {
		$("#dataTable").datagrid({
			toolbar: '#dataSearch',
			fitColumns:true,
			striped: true, 
			singleSelect:false,
			pagination:true,
			rownumbers:true,
			SelectOnCheck:true,
			CheckOnSelect:true,
	        onSelect: function(index,row){
	        	var nos="";
	        	var rows = $('#dataTable').datagrid('getSelections');
	        	for(var i=0; i<rows.length; i++){
	        		nos=nos+rows[i].ck+",";
	        	}
				$("#keys").val(nos);
	    	},
	    	onUnselect: function(index,row){
	        	var nos="";
	        	var rows = $('#dataTable').datagrid('getSelections');
	        	for(var i=0; i<rows.length; i++){
	        		nos=nos+rows[i].ck+",";
	        	}
				$("#keys").val(nos);
	    	},
	    	onSelectAll: function(rows){
	        	var nos="";
	        	for(var i=0; i<rows.length; i++){
	        		nos=nos+rows[i].ck+",";
	        	}
				$("#keys").val(nos);
	    	},
	    	onUnselectAll: function(rows){
				$("#keys").val("");
	    	}
		});

		$('#dataTable').datagrid('getPager').pagination({
			total:<s:property value="pageInfo.pageRecord"/>,
			pageNumber:<s:property value="pageInfo.pageIndex"/>,
			pageSize:<s:property value="pageInfo.pageSize"/>,
			pageList: [20,50,100] ,
			onSelectPage:function(pageNumber,pageSize){  
				toPage(pageNumber,pageSize);
			},
			onRefresh:function(pageNumber,pageSize){  
				location.reload();
			}
		});
	});
</script>
</head>
<body>

	<div id="dataSearch">
		<form id="sform" action="sql.html" method="get" enctype="multipart/form-data">
			<table style="width: 100%;">
				<tr>
					<td height="25" >
						<b>操作说明:只能执行查询语句</b> 
					</td>
				</tr>
				<tr>
					<td height="30">
					<s:textfield name="sqlText" id="sqlText" cssStyle="width:80%;" placeholder="原生查询SQL"></s:textfield> <input type="button" class="submit" value="查询搜索" onclick="sform.submit();" />
					</td>
				</tr>
			</table>
		</form>
	</div>
	
	<s:if test="sqlResult!=null">
	<table id="dataTable" style="width: 100%;" class="easyui-datagrid">
		<thead>
			<tr>
				<th data-options="field:'ck'" checkbox="true"></th>
				<s:iterator value="sqlResult[0]" id="next" status="seq">
					<th data-options="field:'<s:property value="@utils.StringUtil@simple(#next.key)"/>', width:'10%',align:'left' , halign: 'left'"><s:property value="@utils.StringUtil@simple(#next.key)"/></th>
				</s:iterator>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="sqlResult" id="show" status="seq">
				<tr>
					<td></td>
					<s:iterator value="#show" id="next">
						<td><s:property value="#next.value" /></td>
					</s:iterator>
				</tr>
			</s:iterator>
		</tbody>
	</table>
	</s:if>
	<br />
	<br />
	<br />
</body>
</html>
